<?php

namespace Modules\Manager\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Traits\HasRoles;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Manager extends Model
{
    use HasFactory,HasApiTokens,HasRoles;
    protected $guard_name = 'sanctum';
    protected $hidden = ['password'];
    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }
    protected $fillable = ['avatar','wechat_openid','phone','password','department_id','post_id','nick_name','mobile','username','openid','qizong_openid'];
    public function post(){
        return $this->belongsTo(Role::class,'post_id','id');
    }
    public function department(){
        return $this->belongsTo(Department::class,'department_id','id');
    }

}
